clear all

*	---------------------------------------------------------------------------*
*   File Name:      code.do                                                    
*   Author:         Omar García-Ponce and Thomas Zeitzoff                                   
*   Date:           June 23, 2020                                                 
*   Purpose:        Generate results from "Are Voters too Afraid to Tackle Corruption?"                                                                                                                  
*   Machine:        Omar's MacBook Pro                                                
*	Software:       Stata/MP 15
*	---------------------------------------------------------------------------*

* Change working directory here

********************************************************************************
* National Survey Results
********************************************************************************

use "national_survey_data.dta"

* Generate Drug War Intensity variable based on drug-related homicides per 100,000 people

gen dwintensity =0
replace dwintensity =1 if dwkillings>1.25 & dwkillings <6.5
replace dwintensity =2 if dwkillings >=6.5
la var dwintensity "Ordinal variable of Drug War intensity based on drug-related homicides per pop."

*------------------------------------------------------------------------------*
* Figure 3: Histograms of Key Questions in the National Survey                                                                     
*------------------------------------------------------------------------------*

#delimit;

hist fear, scheme(s2mono) yscale(range(0 250)) xlabel(1 "1" 2 "2" 3 "3" 4 "4" 5 "5" 6 "6" 7 "7") frequency d aspect(1) name(fear)
acolor(red) bcolor(gray) blcolor(white) graphregion(color(white))
xtitle("Self-reported Level") ytitle("Frequency") 
title("Fear of Drug War", color(black));

hist tradeoff, scheme(s2mono) yscale(range(0 250)) xlabel(1 "1" 2 "2" 3 "3" 4 "4" 5 "5" 6 "6" 7 "7") frequency d aspect(1) name(tradeoff)
acolor(red) bcolor(gray) blcolor(white) graphregion(color(white))
xtitle("Self-reported Level") ytitle("Frequency") 
title("Corruption Trade-off", color(black));

graph combine fear tradeoff, iscale(0.6); 

graph export figure3.pdf;

#delimit cr

*------------------------------------------------------------------------------*
* Table 1                                                                      
*------------------------------------------------------------------------------*

* Panel A *
eststo clear
set more off
qui reg tradeoff fear [pw=weights], robust cl(seccion)
eststo 
qui reg tradeoff fear Age Male Education [pw=weights], robust cl(seccion)
eststo 
qui reg tradeoff fear Age Male Education pri_mayor log_usdist margindex [pw=weights], robust cl(seccion)
eststo 
qui tobit tradeoff fear [pw=weights], ll ul vce(cl seccion)
eststo 
qui tobit tradeoff fear Age Male Education [pw=weights], ll ul vce(cl seccion)
eststo
qui tobit tradeoff fear Age Male Education pri_mayor log_usdist margindex [pw=weights], ll ul vce(cl seccion) 
eststo
esttab, se b(2) se(2) star(* 0.10 ** 0.05 *** 0.01) stats(N rmse r2) 

* Panel B *
eststo clear
qui reg tradeoff fear [pw=weights] if dwintensity==0, robust cl(seccion)
eststo 
qui reg tradeoff fear Age Male Education [pw=weights] if dwintensity==0, robust cl(seccion)
eststo 
qui reg tradeoff fear Age Male Education pri_mayor log_usdist margindex [pw=weights] if dwintensity==0, robust cl(seccion)
eststo 
qui tobit tradeoff fear [pw=weights] if dwintensity==0, ll ul vce(cl seccion)
eststo 
qui tobit tradeoff fear Age Male Education [pw=weights] if dwintensity==0, ll ul vce(cl seccion)
eststo
qui tobit tradeoff fear Age Male Education pri_mayor log_usdist margindex [pw=weights] if dwintensity==0, ll ul vce(cl seccion) 
eststo
esttab, se b(2) se(2) star(* 0.10 ** 0.05 *** 0.01) stats(N rmse r2) 

* Panel C *
eststo clear
qui reg tradeoff fear [pw=weights] if dwintensity==1, robust cl(seccion)
eststo 
qui reg tradeoff fear Age Male Education [pw=weights] if dwintensity==1, robust cl(seccion)
eststo 
qui reg tradeoff fear Age Male Education pri_mayor log_usdist margindex [pw=weights] if dwintensity==1, robust cl(seccion)
eststo 
qui tobit tradeoff fear [pw=weights] if dwintensity==1, ll ul vce(cl seccion)
eststo 
qui tobit tradeoff fear Age Male Education [pw=weights] if dwintensity==1, ll ul vce(cl seccion)
eststo
qui tobit tradeoff fear Age Male Education pri_mayor log_usdist margindex [pw=weights] if dwintensity==1, ll ul vce(cl seccion) 
eststo
esttab, se b(2) se(2) star(* 0.10 ** 0.05 *** 0.01) stats(N rmse r2) 

* Panel D *
eststo clear
qui reg tradeoff fear [pw=weights] if dwintensity==2, robust cl(seccion)
eststo 
qui reg tradeoff fear Age Male Education [pw=weights] if dwintensity==2, robust cl(seccion)
eststo 
qui reg tradeoff fear Age Male Education pri_mayor log_usdist margindex [pw=weights] if dwintensity==2, robust cl(seccion)
eststo 
qui tobit tradeoff fear [pw=weights] if dwintensity==2, ll ul vce(cl seccion)
eststo 
qui tobit tradeoff fear Age Male Education [pw=weights] if dwintensity==2, ll ul vce(cl seccion)
eststo
qui tobit tradeoff fear Age Male Education pri_mayor log_usdist margindex [pw=weights] if dwintensity==2, ll ul vce(cl seccion) 
eststo
esttab, se b(2) se(2) star(* 0.10 ** 0.05 *** 0.01) stats(N rmse r2) 

********************************************************************************
* Greater Mexico City Experiment Results
********************************************************************************

use "DF_experiment_data.dta", clear

**** Declaring survey design ***
svyset psu [pweight=weights], strata(strata11)

*** Generating crime victimization index ****

* Recode relevant variables 
gen house_robbed=.
replace house_robbed= 5-b4_1 if b4_1<6

gen biz_robbed=.
replace biz_robbed= 5-b4_2 if b4_2<6

gen car_robbed=.
replace car_robbed= 5-b4_3 if b4_3<6

gen assaulted=.
replace assaulted= 5-b4_4 if b4_4<6

gen shot=.
replace shot= 5-b4_5 if b4_5<6

gen killed=.
replace killed= 5-b4_6 if b4_6<6

gen extort=.
replace extort= 5-b4_7 if b4_7<6

gen fraud=.
replace fraud= 5-b4_8 if b4_8<6

gen kidnap=.
replace kidnap= 5-b4_9 if b4_9<6

gen sex_abuse=.
replace sex_abuse= 5-b4_10 if b4_10<6

sum house_robbed biz_robbed car_robbed assault shot killed extort fraud kidnap sex_abuse

* Compute index 
alpha house_robbed biz_robbed car_robbed assault shot killed extort fraud kidnap sex_abuse, item gen (victim_index)

* Having it lie between 0 and 1
sum victim_index
replace victim_index = victim_index/2.8 
sum victim_index

*** Generating index of perceived neighborhood violence ****

* Recode relevant variables
replace b5_1=. if b5_1>10
replace b5_2=. if b5_2>10
replace b5_3=. if b5_3>10
replace b5_4=. if b5_4>10
replace b5_5=. if b5_5>10

* Compute index 
alpha b5_1 b5_2 b5_3 b5_4 b5_5, item gen (neighborsafety_index)

* Having it lie between 0 and 1
sum neighborsafety_index
replace neighborsafety_index=neighborsafety_index/10
sum neighborsafety_index

*** Generating index of perceived neighborhood corruption ****

* Recode relevant variables
replace b6_1=. if b6_1>10
replace b6_2=. if b6_2>10
replace b6_3=. if b6_3>10
replace b6_4=. if b6_4>10

* Compute index 
alpha b6_1 b6_2 b6_3 b6_4 , item gen (corruption_index)

* Having it lie between 0 and 1
sum corruption_index
replace corruption_index= (corruption_index)/10
sum corruption_index

*** Generating stress index ****

* Recode relevant variables
replace b7_1=. if b7_1>8
replace b7_2=. if b7_2>8
replace b7_3=. if b7_3>8
replace b7_4=. if b7_4>8
replace b7_5=. if b7_5>8
replace b7_6=. if b7_6>8
replace b7_7=. if b7_7>8
replace b7_8=. if b7_8>8
replace b7_9=. if b7_9>8
replace b7_10=. if b7_10>8

* Compute index
alpha b7_1 b7_2 b7_3 b7_4 b7_5 b7_6 b7_7 b7_8 b7_9 b7_10, item gen (stress_index)

* Having it lie between 0 and 1
sum stress_index
replace stress_index = (stress_index-1)/3
sum stress_index

*** Label variables used in the analysis ***
la var emotional_treatment "Emotional treatment"
la var victim_index "Crime victimization index"
la var neighborsafety_index "Perceived neighborhood violence"
la var stress_index "Stress index"
la var age "Age"
la var male "Male"
la var education "Education"
la var amlo "AMLO vote"
la var epn "EPN vote"
la var hhsize "Household size"
la var children "Children (dummy variable)"
la var corruption_index "Perceived neighborhood corruption"

*------------------------------------------------------------------------------*
* Table 2: Randomization Check -- Covariate Balance Statistics 
*------------------------------------------------------------------------------*
* Install the 'psmatch2' package in order to use 'pstest'
pstest victim_index age male education children hhsize stress_index amlo epn neighborsafety_index corruption_index, raw t( emotional_treatment) 

*------------------------------------------------------------------------------*
* Table 3: Determinants of Fear over the Drug War
*------------------------------------------------------------------------------*
eststo clear
qui svy: tobit reported_fear emotional_treatment victim_index, ll ul
eststo
qui svy: tobit reported_fear emotional_treatment victim_index age male education children hhsize, ll ul
eststo 
qui svy: tobit reported_fear emotional_treatment victim_index age male education children hhsize stress_index, ll ul
eststo
qui svy: tobit reported_fear emotional_treatment victim_index age male education children hhsize stress_index amlo epn, ll ul
eststo
qui svy: tobit reported_fear emotional_treatment victim_index age male education children hhsize stress_index neighborsafety_index corruption_index amlo epn, ll ul
eststo
#delimit;
esttab, se(%8.2f) b(%8.2f) star(* .10 ** .05 *** .01) nodepvars label nonotes mtitles("" "" "" "" "")
addnotes("All estimates are based on weighted Tobit regressions with both left- and right-censoring." 
"Linearized standard errors in parentheses account for clustering at the electoral precinct level."
"{*}{*}{*} Significant at the 1\% level; {*}{*} significant at
the 5\% level; and {*} significant at the 10\% level");
#delimit cr

*------------------------------------------------------------------------------*
* Table 4: Determinants of Corruption Trade-off 
*------------------------------------------------------------------------------*
eststo clear
qui svy: tobit tradeoff emotional_treatment victim_index, ll ul
eststo
qui svy: tobit tradeoff emotional_treatment victim_index age male education children hhsize, ll ul
eststo 
qui svy: tobit tradeoff emotional_treatment victim_index age male education children hhsize stress_index, ll ul
eststo
qui svy: tobit tradeoff emotional_treatment victim_index age male education children hhsize stress_index amlo epn, ll ul
eststo
qui svy: tobit tradeoff emotional_treatment victim_index age male education children hhsize stress_index neighborsafety_index corruption_index amlo epn, ll ul
eststo
#delimit;
esttab, se(%8.2f) b(%8.2f) star(* .10 ** .05 *** .01) nodepvars label nonotes mtitles("" "" "" "" "")
addnotes("All estimates are based on weighted Tobit regressions with both left- and right-censoring." 
"Linearized standard errors in parentheses account for clustering at the electoral precinct level."
"{*}{*}{*} Significant at the 1\% level; {*}{*} significant at
the 5\% level; and {*} significant at the 10\% level");
#delimit cr

*------------------------------------------------------------------------------*
* Table 5: Determinants of Preference Toward Corruption as Long as the Violence Goes Down
*------------------------------------------------------------------------------*
eststo clear
qui svy: tobit corruption_tolerance emotional_treatment victim_index, ll ul
eststo
qui svy: tobit corruption_tolerance emotional_treatment victim_index age male education children hhsize, ll ul
eststo 
qui svy: tobit corruption_tolerance emotional_treatment victim_index age male education children hhsize stress_index, ll ul
eststo
qui svy: tobit corruption_tolerance emotional_treatment victim_index age male education children hhsize stress_index amlo epn, ll ul
eststo
qui svy: tobit corruption_tolerance emotional_treatment victim_index age male education children hhsize stress_index neighborsafety_index corruption_index amlo epn, ll ul
eststo
#delimit;
esttab, se(%8.2f) b(%8.2f) star(* .10 ** .05 *** .01) nodepvars label nonotes mtitles("" "" "" "" "")
addnotes("All estimates are based on weighted Tobit regressions with both left- and right-censoring." 
"Linearized standard errors in parentheses account for clustering at the electoral precinct level."
"{*}{*}{*} Significant at the 1\% level; {*}{*} significant at
the 5\% level; and {*} significant at the 10\% level");
#delimit cr

*------------------------------------------------------------------------------*
* Table A1: Determinants of Fear over the Drug War in Low Violence Areas
*------------------------------------------------------------------------------*
eststo clear
qui tobit reported_fear emotional_treatment victim_index [pw=weights] if intensity_drug_violence=="Low", ll ul 
eststo
qui tobit reported_fear emotional_treatment victim_index age male education children hhsize [pw=weights] if intensity_drug_violence=="Low", ll ul 
eststo 
qui tobit reported_fear emotional_treatment victim_index age male education children hhsize stress_index [pw=weights] if intensity_drug_violence=="Low", ll ul 
eststo
qui tobit reported_fear emotional_treatment victim_index age male education children hhsize stress_index amlo epn [pw=weights] if intensity_drug_violence=="Low", ll ul 
eststo
qui tobit reported_fear emotional_treatment victim_index age male education children hhsize stress_index neighborsafety_index corruption_index amlo epn [pw=weights] if intensity_drug_violence=="Low", ll ul 
eststo
#delimit;
esttab , se(%8.2f) b(%8.2f) star(* .10 ** .05 *** .01) nodepvars label nonotes mtitles("" "" "" "" "")
addnotes("All estimates are based on weighted Tobit regressions with both left- and right-censoring." 
"Robust standard errors in parentheses account for clustering at the electoral precinct level."
"{*}{*}{*} Significant at the 1\% level; {*}{*} significant at
the 5\% level; and {*} significant at the 10\% level");
#delimit cr

*------------------------------------------------------------------------------*
* Table A2: Determinants of Fear over the Drug War in Medium Violence Areas
*------------------------------------------------------------------------------*
eststo clear
qui tobit reported_fear emotional_treatment victim_index [pw=weights] if intensity_drug_violence=="Medium", ll ul 
eststo
qui tobit reported_fear emotional_treatment victim_index age male education children hhsize [pw=weights] if intensity_drug_violence=="Medium", ll ul 
eststo 
qui tobit reported_fear emotional_treatment victim_index age male education children hhsize stress_index [pw=weights] if intensity_drug_violence=="Medium", ll ul 
eststo
qui tobit reported_fear emotional_treatment victim_index age male education children hhsize stress_index amlo epn [pw=weights] if intensity_drug_violence=="Medium", ll ul 
eststo
qui tobit reported_fear emotional_treatment victim_index age male education children hhsize stress_index neighborsafety_index corruption_index amlo epn [pw=weights] if intensity_drug_violence=="Medium", ll ul 
eststo
#delimit;
esttab , se(%8.2f) b(%8.2f) star(* .10 ** .05 *** .01) nodepvars label nonotes mtitles("" "" "" "" "")
addnotes("All estimates are based on weighted Tobit regressions with both left- and right-censoring." 
"Robust standard errors in parentheses account for clustering at the electoral precinct level."
"{*}{*}{*} Significant at the 1\% level; {*}{*} significant at
the 5\% level; and {*} significant at the 10\% level");
#delimit cr

*------------------------------------------------------------------------------*
* Table A3: Determinants of Fear over the Drug War in High Violence Areas
*------------------------------------------------------------------------------*
eststo clear
qui tobit reported_fear emotional_treatment victim_index [pw=weights] if intensity_drug_violence=="High", ll ul 
eststo
qui tobit reported_fear emotional_treatment victim_index age male education children hhsize [pw=weights] if intensity_drug_violence=="High", ll ul 
eststo 
qui tobit reported_fear emotional_treatment victim_index age male education children hhsize stress_index [pw=weights] if intensity_drug_violence=="High", ll ul 
eststo
qui tobit reported_fear emotional_treatment victim_index age male education children hhsize stress_index amlo epn [pw=weights] if intensity_drug_violence=="High", ll ul 
eststo
qui tobit reported_fear emotional_treatment victim_index age male education children hhsize stress_index neighborsafety_index corruption_index amlo epn [pw=weights] if intensity_drug_violence=="High", ll ul 
eststo
#delimit;
esttab , se(%8.2f) b(%8.2f) star(* .10 ** .05 *** .01) nodepvars label nonotes mtitles("" "" "" "" "")
addnotes("All estimates are based on weighted Tobit regressions with both left- and right-censoring." 
"Robust standard errors in parentheses account for clustering at the electoral precinct level."
"{*}{*}{*} Significant at the 1\% level; {*}{*} significant at
the 5\% level; and {*} significant at the 10\% level");
#delimit cr

*------------------------------------------------------------------------------*
* Table A4: Determinants of Fear over the Drug War (Weighted Least Squares) 
*------------------------------------------------------------------------------*
eststo clear
qui svy: reg reported_fear emotional_treatment victim_index
eststo
qui svy: reg reported_fear emotional_treatment victim_index age male education children hhsize 
eststo 
qui svy: reg reported_fear emotional_treatment victim_index age male education children hhsize stress_index 
eststo
qui svy: reg reported_fear emotional_treatment victim_index age male education children hhsize stress_index amlo epn
eststo
qui svy: reg reported_fear emotional_treatment victim_index age male education children hhsize stress_index neighborsafety_index corruption_index amlo epn
eststo
#delimit;
esttab, se(%8.2f) b(%8.2f) star(* .10 ** .05 *** .01) nodepvars label nonotes mtitles("" "" "" "" "")
addnotes("All estimates are based on weighted least square regressions." 
"Linearized standard errors in parentheses account for clustering at the electoral precinct level."
"{*}{*}{*} Significant at the 1\% level; {*}{*} significant at
the 5\% level; and {*} significant at the 10\% level");
#delimit cr

*------------------------------------------------------------------------------*
* Table A5: Determinants of Corruption Trade-off (Weighted Least Squares) 
*------------------------------------------------------------------------------*
eststo clear
qui svy: reg tradeoff emotional_treatment victim_index
eststo
qui svy: reg tradeoff emotional_treatment victim_index age male education children hhsize
eststo 
qui svy: reg tradeoff emotional_treatment victim_index age male education children hhsize stress_index
eststo
qui svy: reg tradeoff emotional_treatment victim_index age male education children hhsize stress_index amlo epn
eststo
qui svy: reg tradeoff emotional_treatment victim_index age male education children hhsize stress_index neighborsafety_index corruption_index amlo epn
eststo
#delimit;
esttab, se(%8.2f) b(%8.2f) star(* .10 ** .05 *** .01) nodepvars label nonotes mtitles("" "" "" "" "")
addnotes("All estimates are based on weighted Tobit regressions with both left- and right-censoring." 
"Linearized standard errors in parentheses account for clustering at the electoral precinct level."
"{*}{*}{*} Significant at the 1\% level; {*}{*} significant at
the 5\% level; and {*} significant at the 10\% level");
#delimit cr

*------------------------------------------------------------------------------*
* Table A6: Determinants of Preference Toward Corruption as Long as the Violence Goes Down (Weighted Least Squares) 
*------------------------------------------------------------------------------*
eststo clear
qui svy: reg corruption_tolerance emotional_treatment victim_index
eststo
qui svy: reg corruption_tolerance emotional_treatment victim_index age male education children hhsize
eststo 
qui svy: reg corruption_tolerance emotional_treatment victim_index age male education children hhsize stress_index
eststo
qui svy: reg corruption_tolerance emotional_treatment victim_index age male education children hhsize stress_index amlo epn
eststo
qui svy: reg corruption_tolerance emotional_treatment victim_index age male education children hhsize stress_index neighborsafety_index corruption_index amlo epn
eststo
#delimit;
esttab, se(%8.2f) b(%8.2f) star(* .10 ** .05 *** .01) nodepvars label nonotes mtitles("" "" "" "" "")
addnotes("All estimates are based on weighted Tobit regressions with both left- and right-censoring." 
"Linearized standard errors in parentheses account for clustering at the electoral precinct level."
"{*}{*}{*} Significant at the 1\% level; {*}{*} significant at
the 5\% level; and {*} significant at the 10\% level");
#delimit cr

*------------------------------------------------------------------------------*
* Table A7: Determinants of Corruption Trade-off (Using Self-Reported Fear)
*------------------------------------------------------------------------------*
eststo clear
qui svy: tobit tradeoff reported_fear victim_index, ll ul
eststo
qui svy: tobit tradeoff reported_fear victim_index age male education children hhsize, ll ul
eststo 
qui svy: tobit tradeoff reported_fear victim_index age male education children hhsize stress_index, ll ul
eststo
qui svy: tobit tradeoff reported_fear victim_index age male education children hhsize stress_index amlo epn, ll ul
eststo
qui svy: tobit tradeoff reported_fear victim_index age male education children hhsize stress_index neighborsafety_index corruption_index amlo epn, ll ul
eststo
#delimit;
esttab, se(%8.2f) b(%8.2f) star(* .10 ** .05 *** .01) nodepvars label nonotes mtitles("" "" "" "" "")
addnotes("All estimates are based on weighted Tobit regressions with both left- and right-censoring." 
"Linearized standard errors in parentheses account for clustering at the electoral precinct level."
"{*}{*}{*} Significant at the 1\% level; {*}{*} significant at
the 5\% level; and {*} significant at the 10\% level");
#delimit cr

*------------------------------------------------------------------------------*
* Table A8: Determinants of Preference Toward Corruption as Long as the Violence Goes Down (Using Self-Reported Fear)
*------------------------------------------------------------------------------*
eststo clear
qui svy: tobit corruption_tolerance reported_fear victim_index, ll ul
eststo
qui svy: tobit corruption_tolerance reported_fear victim_index age male education children hhsize, ll ul
eststo 
qui svy: tobit corruption_tolerance reported_fear victim_index age male education children hhsize stress_index, ll ul
eststo
qui svy: tobit corruption_tolerance reported_fear victim_index age male education children hhsize stress_index amlo epn, ll ul
eststo
qui svy: tobit corruption_tolerance reported_fear victim_index age male education children hhsize stress_index neighborsafety_index corruption_index amlo epn, ll ul
eststo
#delimit;
esttab, se(%8.2f) b(%8.2f) star(* .10 ** .05 *** .01) nodepvars label nonotes mtitles("" "" "" "" "")
addnotes("All estimates are based on weighted Tobit regressions with both left- and right-censoring." 
"Linearized standard errors in parentheses account for clustering at the electoral precinct level."
"{*}{*}{*} Significant at the 1\% level; {*}{*} significant at
the 5\% level; and {*} significant at the 10\% level");
#delimit cr



